####Autocratic Revolving Doors####
####Roman-Gabriel Olar####
####Created on 17/02/2022####
####Last modified on 12/10/2024####

# load library
library(forcats)
library(ggplot2)
library(haven) 
library(foreign)
library(ggthemes)
library(tidyverse)
library(dplyr)
library(ggpubr)

## Set wd
setwd("C:/Users/Administrator/Dropbox/Papers/ARD Elites/Draft/ARD Observational/PoP/Final submission/Data")
## Load datasets
df<-read_dta("Figure_A5.dta")
df2<-read_dta("Figure_A6.dta")
df3<-read_dta("Figure_A3.dta")
df4<-read_dta("Figure_A4.dta")

# Figure A3
df3 %>%
  mutate(gwf_country = fct_reorder(gwf_country, desc(prop_dem_ARD))) %>%
  ggplot( aes(x=gwf_country, y=prop_dem_ARD)) +
  geom_bar(stat="identity", alpha=.8, width=.5) +
  coord_flip() +
  xlab("") + scale_y_continuous(name="Proportion of democratic elites that are ARD", breaks=seq(0,.50,.05)) +
  theme_bw() +  theme(axis.text.y = element_text(size =8, angle = 360,hjust=1,vjust=0.5))


# Figure A4
df4 %>%
  mutate(gwf_country = fct_reorder(gwf_country, desc(prop_dem_ARD))) %>%
  ggplot( aes(x=gwf_country, y=prop_dem_ARD)) +
  geom_bar(stat="identity", alpha=.8, width=.5) +
  coord_flip() +
  xlab("") + scale_y_continuous(name="Proportion of democratic elites that are ARD", breaks=seq(0,.50,.05)) +
  theme_bw() +  theme(axis.text.y = element_text(size =8, angle = 360,hjust=1,vjust=0.5))

# Figure A5
df %>%
  mutate(gwf_country = fct_reorder(gwf_country, desc(prop_ARD))) %>%
  ggplot( aes(x=gwf_country, y=prop_ARD)) +
  geom_bar(stat="identity", alpha=.8, width=.5) +
  coord_flip() +
  xlab("") + scale_y_continuous(name="Proportion of ARD elites from autocratic cohort", breaks=seq(0,.35,.05)) +
  theme_bw() +  theme(axis.text.y = element_text(size =8, angle = 360,hjust=1,vjust=0.5))

# Figure A6
df2 %>%
  mutate(gwf_country = fct_reorder(gwf_country, desc(prop_ARD))) %>%
  ggplot( aes(x=gwf_country, y=prop_ARD)) +
  geom_bar(stat="identity", alpha=.8, width=.5) +
  coord_flip() +
  xlab("") + scale_y_continuous(name="Proportion of ARD elites from autocratic cohort", breaks=seq(0,.35,.05)) +
  theme_bw() +  theme(axis.text.y = element_text(size =8, angle = 360,hjust=1,vjust=0.5))




